package com.util;

import java.io.File;
import java.net.URL;

/**
 * @author Ricky
 * @date 2020-8-12 15:25
 */
public class PathUtil {

    public static URL getURL(String filePath) {
        return PathUtil.class.getClassLoader().getResource(filePath);
    }

    public static String resolve(String... path) {
        StringBuilder sb = new StringBuilder();
        String separator = File.separator;
        for (String p : path) {
            sb.append(separator).append(p);
        }
        return sb.substring(separator.length());
    }

    public static String getUserDataPath() {
        String userHomeDir = System.getProperty("user.home");
        return resolve(userHomeDir, "AppData", "Roaming", "xunwenjietu");
    }
}
